package com.yootk.listener;

import jakarta.servlet.http.HttpSessionActivationListener;
import jakarta.servlet.http.HttpSessionEvent;

import java.io.Serializable;

/**
 * Session持久化监听
 */
public class SessionStoreListener implements HttpSessionActivationListener, Serializable {
    private String userid;

    public SessionStoreListener(String userid) {
        this.userid = userid;
    }

    @Override
    public void sessionDidActivate(HttpSessionEvent se) {
        System.out.println("【Session激活】SessionId = " + se.getSession().getId() + "、userid = " + this.userid);
    }

    @Override
    public void sessionWillPassivate(HttpSessionEvent se) {
        System.out.println("【Session钝化】SessionId = " + se.getSession().getId() + "、userid = " + this.userid);
    }
}
